package com.xu.cloud.common.pojo.http.req;

import com.xu.cloud.common.pojo.dto.OrderColumnDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 分页查询请求体
 *
 * @author persimmon
 * @since 2023/3/29
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class PageReq extends BaseRequest {
    private static final long serialVersionUID = 4596851132911493511L;

    public static final int defaultPageNum = 1;
    public static final int defaultPageSize = 20;

    /**
     * 页码
     */
    private int pageNum = defaultPageNum;

    /**
     * 每页数量
     */
    private int pageSize = defaultPageSize;

    /**
     * 排序字段
     */
    private List<OrderColumnDTO> orderColumns;

    public int offset() {
        return (pageNum - 1) * pageSize;
    }
}
